﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace ClassLibrary1
{
    public class Resim : Panel
    {
        public Resim()
            : base()
        {

            pic.MouseMove += new MouseEventHandler(Resim_MouseMove);
            pic.MouseLeave += new EventHandler(Resim_MouseLeave);
            pic.MouseUp += new MouseEventHandler(pic_MouseUp);
            this.Height = 95;
            this.Width = 46;
            this.Controls.Add(pic);
            pic.Height = 50;
            pic.SizeMode = PictureBoxSizeMode.Zoom;
            this.Controls.Add(lb);
            lb.AutoSize = true;
            lb.Text = "hazır";
            lb.Dock = DockStyle.Top;
            pic.Dock = DockStyle.Top;
            pic.SendToBack();
            lb.Height = 45;
            tm.Interval = 10;
            tm.Tick += new EventHandler(tm_Tick);
            lb.Font = new System.Drawing.Font((new System.Drawing.FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif)), 6, System.Drawing.FontStyle.Italic);
            pic.Image = global::ClassLibrary1.Properties.Resources.Image1;

        }

        void pic_MouseUp(object sender, MouseEventArgs e)
        {



        }

        void Resim_MouseLeave(object sender, EventArgs e)
        {
            buyuk = true;
            tm.Start();
        }
        int sayi = 0;
        void tm_Tick(object sender, EventArgs e)
        {
            if (buyuk)
            {
                if (sayi == 0)
                {
                    buyuk = false;
                    if (Convert.ToInt32(gb.Tag)<gb.Width-140)
                    {
                       gb.Height -= 160;
                    gb.Width -= 150;
                     
                    }
                    tm.Stop();
                    this.BackColor = Color.Transparent;
                    lb.Font = new System.Drawing.Font((new System.Drawing.FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif)), 6, System.Drawing.FontStyle.Italic);

                }
                else
                {
                    if (gb.buyume == Buyume.Sola)
                    {
                        gb.Left += 10;
                    }

                    this.Height -= 10;
                    this.Width -= 10;
                    //gb.Height -= 10;
                    pic.Height -= 10;
                    sayi--;

                }
            }
            else
            {
                if (sayi > 12)
                {
                    buyuk = true;
                    tm.Stop();
                    this.BackColor = Color.AntiqueWhite;
                    lb.Font = new System.Drawing.Font((new System.Drawing.FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif)), 12, System.Drawing.FontStyle.Italic);
                }
                this.Height += 10;
                this.Width += 10;
                if (gb.buyume == Buyume.Sola)
                {
                    gb.Left -= 10;
                }
                //gb.Height += 10;
                pic.Height += 10;
                sayi++;
            }
        }
        bool buyuk = false;
        Seviye gb;
        Timer tm = new Timer();
        void Resim_MouseMove(object sender, MouseEventArgs e)
        {
            gb = ((FlowLayoutPanel)this.Parent).Parent as Seviye;
            if (gb.Height < 210)
            {
                gb.Height += 160;
                gb.Width += 150;

            }
            if (!buyuk)
            {
                tm.Start();

            }
        }
        PictureBox pic = new PictureBox();
        Label lb = new Label();
        public string Isim { get { return Isim; } set { lb.Text = value; } }
        public System.Drawing.Image PerResim { get { return PerResim; } set { pic.Image = value; } }
        public string resimlocasyon { get { return resimlocasyon; } set { pic.ImageLocation = value; } }
    }
}
